﻿(function () {
    NSFile("Gianduia.AppKit.NSResponder");
    NSImport("Gianduia.Foundation.NSObject");
    NSClass("Gianduia.AppKit.NSResponder").Extends("Gianduia.Foundation.NSObject").Implements({
        "+load": function () {
            this._responderById = new Gianduia.Foundation.NSStringKeyDictionary;
            if (this === Gianduia.AppKit.NSResponder) {
                var A = 0, B, C = ["mouseDown", "rightMouseDown", "otherMouseDown", "mouseUp", "rightMouseUp", "otherMouseUp", "mouseClick", "rightMouseClick", "otherMouseClick", "mouseMoved", "mouseDragged", "scrollWheel", "rightMouseDragged", "otherMouseDragged", "mouseEntered", "mouseExited", "keyDown", "keyUp", "flagsChanged", "tabletPoint", "tabletProximity", "cursorUpdate", "focus", "keyPress"];
                for (A = 0; (B = C[A]); A++) {
                    C[B] = function (D) {
                        this.forwardMethod(B, D)
                    }
                } this.Implements(C)
            }
        }, delegate: NSDelegateProperty({
            delegateSelectorNames: "accumulatedDelegateFlagNames"
        }), "+accumulatedDelegateFlagNames": function () {
            if (!this.hasOwnProperty("__accumulatedDelegateFlagNames")) {
                var A = this.superclass().accumulatedDelegateFlagNames();
                if (A && A.length > 0) {
                    A = A.slice(0)
                } else {
                    A = []
                } A.addObjectsFromArray(this.delegateFlagNames());
                this.__accumulatedDelegateFlagNames = A
            } return this.__accumulatedDelegateFlagNames
        }, accumulatedDelegateFlagNames: function () {
            return this.constructor.accumulatedDelegateFlagNames()
        }, "static _delegateFlagNames": ["responderShouldAcceptFirstResponderWithValue", "responderShouldBecomeFirstResponderWithValue", "responderShouldResignFirstResponderWithValueCandidate"], "+delegateFlagNames": function () {
            return this._delegateFlagNames
        }, "static _eventResponderTable": null, nextResponder: NSProperty(), forwardMethod: function (A, B) {
            var C = this._shouldPostEventNotifications();
            if (this._nextResponder) {
                if (this._nextResponder != this) {
                    this._nextResponder.performSelectorWithObject(A, B)
                } else {
                    NSLog("" + this + " is its own nextResponder");
                    this.noResponderFor(A)
                }
            } else {
                this.noResponderFor(A)
            } if (C && this._shouldPostEventNotifications()) {
                this._postEventNotification(B)
            }
        }, tryToPerformWith: function (B, A) {
            if (this.respondsToSelector(B)) {
                this.performSelectorWithObject(B, A);
                return true
            } else {
                if (this._nextResponder) {
                    return this._nextResponder.tryToPerformWith(B, A)
                }
            } return false
        }, performKeyEquivalent: function (A) {
            return false
        }, performMnemonic: function (A) {
            return false
        }, noResponderFor: function (A) {
            if (A === "keyDown") {
                NSLog("noResponderFor: Beep")
            }
        }, isFirstReponder: function () {
            return window._nsWindow.firstResponder() === this
        }, firstResponderDelegateResponseForSelectorWithValue: function (A, C) {
            var B;
            if (this._delegate && this._delegate.respondsToSelector(A)) {
                B = [this];
                B.addObjectsFromArgumentsInRange(arguments, NSMakeRange(1, arguments.length - 1));
                return this._delegate.performSelectorWithObjects(A, B)
            } return C
        }, acceptsFirstResponder: function () {
            return false
        }, _acceptsFirstResponder: function () {
            return this.firstResponderDelegateResponseForSelectorWithValue("responderShouldAcceptFirstResponderWithValue", this.acceptsFirstResponder())
        }, becomeFirstResponder: function () {
            return true
        }, _becomeFirstResponder: function () {
            return this.firstResponderDelegateResponseForSelectorWithValue("responderShouldBecomeFirstResponderWithValue", this.becomeFirstResponder())
        }, resignFirstResponder: function (A) {
            return true
        }, _resignFirstResponder: function (A) {
            return this.firstResponderDelegateResponseForSelectorWithValue("responderShouldResignFirstResponderWithValueCandidate", this.resignFirstResponder(), A)
        }, undoManager: function () {
            return this._nextResponder ? this._nextResponder.undoManager() : null
        }, helpRequested: function (B) {
            var A = Gianduia.AppKit.NSHelpManager.sharedHelpManager(), D, C;
            if (B) {
                D = B.window().convertBaseToScreen(B.locationInWindow())
            } else {
                C = NSMakeRect(0, 0, screen.width, screen.height);
                D = NSMakePoint(NSMidX(C), NSMidY(C))
            } if (!A || !A.showContextHelpForObjectLocationHint(this, D)) {
                if (this.nextResponder()) {
                    this.nextResponder().performSelectorWithObject("helpRequested", B)
                } else {
                    NSLog("helpRequested: Beep")
                }
            }
        }, showContextHelp: function (A) {
            this.helpRequested(Gianduia.AppKit.NSMenu._contextMenuEvent())
        }, _shouldPostEventNotifications: function () {
            return false
        }, presentErrorModalForWindowDelegateDidPresentSelectorContextInfo: function (G, B, F, E, A) {
            var D = this.willPresentError(G), C = this.nextResponder();
            ((C ? C : document.rootComponent)).presentErrorModalForWindowDelegateDidPresentSelectorContextInfo(D, B, F, E, A)
        }, presentError: function (C) {
            var B = this.willPresentError(C), A = this.nextResponder();
            return ((A ? A : NSApp)).presentError(B)
        }, willPresentError: function (A) {
            return A
        }, touchesBegan_withEvent_: function (B, A) {
        }, touchesMoved_withEvent_: function (B, A) {
        }, touchesEnded_withEvent_: function (B, A) {
        }, touchesCancelled_withEvent_: function (B, A) {
        }
    })
})();
